package org.pictual.action;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.pictual.util.Bloque;
import org.pictual.util.Elemento;
import org.pictual.util.RequestKeys;

public class TipsAction extends DispatchAction {

	public ActionForward learning(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		if(request.getParameter(RequestKeys.LANGUAGE)!=null){
			Locale locale = new Locale(request.getParameter(RequestKeys.LANGUAGE), "");
			request.getSession().setAttribute(org.apache.struts.Globals.LOCALE_KEY,locale);
		}
		
		/*	Bloque de enlaces 1	*/
		Elemento elemento1_1 = new Elemento("1.", "tips.learning.elemento1.1", "www.pictual.org");
		Elemento elemento2_1 = new Elemento("2.", "tips.learning.elemento2_1", "tips_archiv.do", true);
		
		Bloque bloque1 = new Bloque("tips.learning.bloque1", elemento1_1, elemento2_1);
		
		request.setAttribute(RequestKeys.BLOQUE, bloque1);
		request.setAttribute(RequestKeys.TITULO_BLOQUE, bloque1.getTitulo());
		return mapping.findForward("success");
	}
	
	
	public ActionForward archiv(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		
		/*	Bloque de enlaces 1	*/
		Elemento elemento1_1 = new Elemento("1.", "tips.archiv.elemento1.1", "www.pictual.org");
		Elemento elemento2_1 = new Elemento("2.", "tips.archiv.elemento2.1");
		
		Bloque bloque1 = new Bloque("tips.archiv.bloque1", elemento1_1, elemento2_1);
		
		request.setAttribute(RequestKeys.BLOQUE, bloque1);
		request.setAttribute(RequestKeys.TITULO_BLOQUE, bloque1.getTitulo());
		
		return mapping.findForward("success");
	}
}
